<?php 
class mhome extends CI_Model{
    function __construct(){
        parent::__construct();
    }
	
	function getdata($type, $param1="", $param2="", $param3="", $param4=""){
		switch($type){
			case 'kategori_menu_atas':
				$sql = "
					SELECT A.*
					FROM cl_kategori_content A
					WHERE A.flag_menu = 'Y'
				";
				return $this->db->query($sql)->result_array();
			break;
			case 'kategori_menu_samping':
				$sql = "
					SELECT A.*
					FROM cl_kategori_content A
					WHERE A.flag_menu = 'N'
				";
				return $this->db->query($sql)->result_array();
			break;
			case 'subkategori_menu':
			//perubahan menu profile makasar dan dinas tidak di tampilan di list sub menu
				$sql = "
					SELECT A.*
					FROM cl_subkategori_content A
					WHERE A.cl_kategori_content_id = '".$param1."' AND A.id != '31' AND A.id != '32' 
				";
				return $this->db->query($sql)->result_array();
			break;
			case 'kontent':
				$sql = "
					SELECT A.*
					FROM tbl_content A
					WHERE A.cl_subkategori_content_id = '".$param1."'
				";
				return $this->db->query($sql)->row();
			break;
			case 'cari_konten':
				$sql = "
					SELECT A.*
					FROM tbl_content A
					WHERE A.isi like '%".$this->db->escape_str($param1)."%'
				";
				return $this->db->query($sql)->result_array();
			break;
			case 'cari_berita':
				$sql = "
					SELECT A.*
					FROM tbl_berita A
					WHERE A.judul_berita like '%".$this->db->escape_str($param1)."%'
				";
				return $this->db->query($sql)->result_array();
			break;
		}
	}
		
	function getprofile($id){
		$this->db->flush_cache();
		$this->db->select("*");
		$this->db->from("tbl_content");
		$this->db->where('id', $id);
		$r = $this->db->get();
		
		$str = $r->row()->isi;
		$str = strip_tags($str);
		
		return substr($str, 0, 430);
	}
}